package test;

public class SleepExample {

    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            System.out.println("Thread 1 started");
            try {
                Thread.sleep(2000); // 让线程睡眠2秒钟
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("Thread 1 finished");
        });

        Thread t2 = new Thread(() -> {
            System.out.println("Thread 2 started");
            try {
                Thread.sleep(1000); // 让线程睡眠1秒钟
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("Thread 2 finished");
        });

        t1.start();
        t2.start();
    }
}
